package cn.example.vip.mall.page.service.impl;

import cn.example.vip.mall.page.service.ItemService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

@Service
public class ItemServiceImpl implements ItemService {
	
	@Value("${items.pagepath}")
	private String pagepath;
	
	@Override
	public String getItemPage(String id) {
//		File file = new File(pagepath + "/" + id + ".html");
//		byte[] pageData = null;
//		if (!file.exists()) {
//			throw new RuntimeException("找不到页面!");
//		}
//		try {
//			pageData = new byte[(int) file.length()];
//			FileInputStream fis = new FileInputStream(file);
//			fis.read(pageData, 0, (int) file.length());
//		} catch (FileNotFoundException e) {
//			e.printStackTrace();
//		} catch (IOException e) {
//			throw new RuntimeException(e);
//		}
//
//		String pageStr = new String(pageData);
////		System.err.println(pageStr);
//		return pageStr;
		return "../static/" + id + ".html";
	}
}
